<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    echo heading("Cadastrar Contas",4,"class='divisor'");
    $id = $this->uri->segment(3);
    //$query = $this->ContaModel->getIdConta($id)->row();
    if($id == NULL)
    {	$id_conta = 1;
	$descricao = 'Gerenciador Financeiro';
    }
    else
    { 	$query = $this->ContaModel->getIdConta($id)->row();
	$id_conta = $query->id_conta;
	$descricao = $query->descricao;
    }
    $atributos_formulario = array('class' => 'form-signin', 'id'=>'formcadastro');
    echo form_open ("contaController/adicionarConta/$id",$atributos_formulario);
        if(validation_errors())
        { echo '<div class="alert alert-danger">
                <button type="button" class="close " data-dismiss="alert">&times;</button>
                <span>'.validation_errors().'</span> 
            </div>';
        } 
        if($this->session->flashdata('cadastrook')):
            echo "<div class=alerta>";
                    echo "<p class='validacoes'>".$this->session->flashdata('cadastrook')."</p>";
            echo "</div>";
        endif;
        echo form_label('Sub Conta em ::','conta');
        echo form_input(array('name'=>'id_conta_pai', 'type'=>'hidden'),  set_value('id_conta_pai',$id_conta));
        echo form_input(array('name'=>''),  set_value('descricaoContaPai',$descricao) ,'disabled="disabled"');
        echo form_label('Descrição da Conta ::','conta');
        echo form_input(array('name'=>'descricao','class'=>'input-xsmall','placeholder'=>'Descrição da Conta'),  set_value('descricao'),'autofocus');
        echo br();
        $btnGravar = array('name' => 'button','id' => 'button','value' => 'true','type' => 'submit', 'content' => 'Gravar', 'class' => 'btn btn-primary');
        echo form_button($btnGravar);
        echo nbs(4);                                
        $btnLimpar = array('name' => 'button', 'id' => 'button', 'value' => 'true', 'type' => 'reset', 'content' => 'Limpar', 'class' => 'btn btn-primary');
        echo form_button($btnLimpar);
        echo nbs(4);
        echo anchor("PrincipalController/",' Voltar ', array('title' =>'Voltar para principal', 'class' => 'btn btn-danger'));
        echo form_close();
    ?>